package com.lemon.smartsafetynew.ui.activity.record;

import android.os.Bundle;
import android.util.Log;

import com.lemon.smartsafety.R;
import com.lemon.smartsafety.app.AppManager;
import com.lemon.smartsafety.app.ApplicationInfo;
import com.lemon.smartsafety.utils.app.UIHelper;
import com.lemon.smartsafetynew.ui.activity.base.SwipeBackActivity;
import com.lemon.smartsafetynew.entity.record.FunctionVo;
import com.lemon.smartsafetynew.ui.fragment.record.CompanySearchFragment;
import com.lemon.smartsafetynew.util.constants.KeyConstants;

/**
 * Created by lzh on 2018/3/17.
 */

public class CompanySearchActivity extends SwipeBackActivity {
    private CompanySearchFragment companyListFragment;
    private static FunctionVo functionVo;

    @Override
    protected void getBundleArgs() {
        super.getBundleArgs();
        Bundle bundle = getIntent().getExtras();
        if (bundle != null) {
            if (bundle.containsKey(KeyConstants.KEY_DOCS_VO)) {
                functionVo = (FunctionVo) bundle.getSerializable(KeyConstants.KEY_DOCS_VO);
            }
        }
    }

    @Override
    protected int getContentViewId() {
        return R.layout.activity_fragment;
    }

    @Override
    protected void initTitle() {
        String titleText = "";
        if (ApplicationInfo.RecordFunctionEnum.LOACL_PATROL_TYPE.equals(functionVo.getRecordFunctionEnum())) {
            // 检查点位
            titleText = getString(R.string.record_patrol_name);
            functionVo.setType("check_point");
        } else if (ApplicationInfo.RecordFunctionEnum.LOACL_HIDDEN_TYPE.equals(functionVo.getRecordFunctionEnum())) {
            // 隐患记录
            titleText = getString(R.string.record_hidden_name);
            functionVo.setType("hidden_danger");
        } else if (ApplicationInfo.RecordFunctionEnum.WEB_NORMAL_INFO_TYPE.equals(functionVo.getRecordFunctionEnum())) {
            // 基本信息
            titleText = getString(R.string.record_normal_name);
            functionVo.setType("else");
        } else if (ApplicationInfo.RecordFunctionEnum.WEB_PERSON_TYPE.equals(functionVo.getRecordFunctionEnum())) {
            // 企业人员
            titleText = getString(R.string.record_person_name);
            functionVo.setType("company_people");
        } else if (ApplicationInfo.RecordFunctionEnum.WEB_MAJOR_HAZARD_TYPE.equals(functionVo.getRecordFunctionEnum())) {
            // 重大危险源
            titleText = getString(R.string.record_major_hazard_name);
            functionVo.setType("danger");
        } else if (ApplicationInfo.RecordFunctionEnum.WEB_SPECIAL_EQUIPMENT_TYPE.equals(functionVo.getRecordFunctionEnum())) {
            // 特种设备
            titleText = getString(R.string.record_special_equipment_name);
            functionVo.setType("special");
        } else if (ApplicationInfo.RecordFunctionEnum.WEB_MATERIALS_INFO_TYPE.equals(functionVo.getRecordFunctionEnum())) {
            // 物料信息
            titleText = getString(R.string.record_materials_name);
            functionVo.setType("materiel");
        } else if (ApplicationInfo.RecordFunctionEnum.WEB_TANKS_INFO_TYPE.equals(functionVo.getRecordFunctionEnum())) {
            // 储罐信息
            titleText = getString(R.string.record_tanks_name);
            functionVo.setType("tank");
        } else if (ApplicationInfo.RecordFunctionEnum.WEB_DUST_INFO_TYPE.equals(functionVo.getRecordFunctionEnum())) {
            // 粉尘信息
            titleText = getString(R.string.record_dust_name);
            functionVo.setType("dust");
        } else if (ApplicationInfo.RecordFunctionEnum.WEB_CONFINED_SPACE_TYPE.equals(functionVo.getRecordFunctionEnum())) {
            // 受限空间
            titleText = getString(R.string.record_confined_space_name);
            functionVo.setType("space");
        } else if (ApplicationInfo.RecordFunctionEnum.LOCAL_ELECTRICAL_TYPE.equals(functionVo.getRecordFunctionEnum())) {
            // 配电箱信息
            titleText = getString(R.string.record_electrical_info);
            functionVo.setType("electric");
        } else if (ApplicationInfo.RecordFunctionEnum.LOCAL_AIR_TYPE.equals(functionVo.getRecordFunctionEnum())) {
            // 可燃气体
            titleText = getString(R.string.record_air_info);
            functionVo.setType("gas");
        } else if (ApplicationInfo.RecordFunctionEnum.LOCAL_HIGH_DANGER_TYPE.equals(functionVo.getRecordFunctionEnum())) {
            // 高危工艺
            titleText = getString(R.string.record_high_danger_info);
            functionVo.setType("high");
        } else if (ApplicationInfo.RecordFunctionEnum.LOCAL_METALLURGY_TYPE.equals(functionVo.getRecordFunctionEnum())) {
            // 冶金信息
            titleText = getString(R.string.record_metallurgy);
            functionVo.setType("metall");
        } else if (ApplicationInfo.RecordFunctionEnum.LOCAL_AMMONIA_TYPE.equals(functionVo.getRecordFunctionEnum())) {
            // 液氨信息
            titleText = getString(R.string.record_ammonia_info);
            functionVo.setType("ammonia");
            ;
        } else if (ApplicationInfo.RecordFunctionEnum.LOCAL_OCCUPATIONA_TYPE.equals(functionVo.getRecordFunctionEnum())) {
            // 职业病危害信息
            titleText = getString(R.string.record_occupationa_info);
            functionVo.setType("occupation");
        } else if (ApplicationInfo.RecordFunctionEnum.LOCAL_EMERGENCY_TYPE.equals(functionVo.getRecordFunctionEnum())) {
            // 应急物资
            titleText = getString(R.string.record_emergency_info);
            functionVo.setType("emer_material");
        } else if (ApplicationInfo.RecordFunctionEnum.LOCAL_SPECISL_TASK_TYPE.equals(functionVo.getRecordFunctionEnum())) {
            // 特种作业操作证人员
            titleText = getString(R.string.record_special_task_info);
            functionVo.setType("special_equipment_operator");
        } else if (ApplicationInfo.RecordFunctionEnum.LOCAL_COMPANY_TRAINING_TYPE.equals(functionVo.getRecordFunctionEnum())) {
            // 企业安全培训信息
            titleText = getString(R.string.record_safe_train_info);
            functionVo.setType("safety_training");
        } else if (ApplicationInfo.RecordFunctionEnum.LOCAL_EMERGENCY_PLAN_TYPE.equals(functionVo.getRecordFunctionEnum())) {
            // 企业应急预案
            titleText = getString(R.string.record_emergrncy_plan_info);
            functionVo.setType("emer_plan");
        }
        this.setBarTitle(titleText);
    }

    @Override
    protected void callFinish() {
        AppManager.getAppManager().finishActivity(CompanySearchActivity.this);
    }

    @Override
    protected void initViews() {
        super.initViews();
        initFragment();

    }

    private void initFragment() {
        companyListFragment = CompanySearchFragment.newInstance(functionVo);
        getSupportFragmentManager().beginTransaction().replace(R.id.frameLayout, companyListFragment).commit();
    }

}
